/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     struct ListNode *next;
 * };
 */


struct ListNode* removeNthFromEnd(struct ListNode* head, int n){
    typedef struct ListNode Node;
    Node node = {0, head};
    Node *first = &node;
    while (n >= 0) {
        first = first->next;
        n--;
    }

    Node *second = &node;
    while (first != NULL) {
        first = first->next;
        second = second->next;
    }

    second->next = second->next->next;
    return node.next;
}

